import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

class ArtefactItem {
  Cluster.Artefact artefact;
  Cluster location;

  ArtefactItem(Cluster.Artefact artefact, Cluster location) {
    this.artefact = artefact;
    this.location = location;
  }

  public boolean validateArtefactBy(String name) {
    return artefact.getName().equals(name);
  }

  public boolean validateLocation(Cluster cluster) {
    if (cluster == null) return false;
    return location.getName().equals(cluster.getName());
  }

  public String getName() {
    return artefact.getName();
  }

  public Cluster.Artefact getArtefact() {
    return artefact;
  }
}

public class Player {
  private String name;
  private Cluster currentLocation;
  private final List<ArtefactItem> artefacts = new ArrayList<>();

  private int health;

  Player(String name, IEntity entity) {
    setName(name);
    setHealth(3);
    setCurrentLocation(entity.getStart());
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getName() {
    return name;
  }

  public void setCurrentLocation(Cluster currentLocation) {
    this.currentLocation = currentLocation;
  }

  public Cluster getCurrentLocation() {
    return currentLocation;
  }

  public boolean peekHaveArtefact(String name) {
    return getArtefacts().stream().anyMatch(artefact -> artefact.validateArtefactBy(name));
  }

  public boolean peekCurrentLocationHaveFurnitureBy(String name) {
    return getCurrentLocation().getFurnitureBy(name).isPresent();
  }

  public boolean peekCurrentLocationHaveCharacterBy(String name) {
    return getCurrentLocation().getCharacterBy(name).isPresent();
  }

  public List<ArtefactItem> getArtefacts() {
    return artefacts;
  }

  public Optional<ArtefactItem> removeArtefactBy(String name) {
    var artefact = artefacts.stream().filter(a -> a.validateArtefactBy(name)).findFirst().orElse(null);
    if (artefacts.remove(artefact)) {
      return Optional.ofNullable(artefact);
    }
    return Optional.empty();
  }

  public int getHealth() {
    return health;
  }

  public void setHealth(int health) {
    this.health = health;
  }

  public void addArtefact(ArtefactItem artefactItem) {
    getArtefacts().add(artefactItem);
  }
}
